//
//  XCCellForHeader.m
//  TTLestening
//
//  Created by dllo on 16/3/23.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "XCCellForHeader.h"
#import "XCModelForHeader.h"

#define WIDGHT  self.contentView.frame.size.width
#define HEIGHT  self.contentView.frame.size.height

#define WIDGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667


@interface XCCellForHeader ()

@property (nonatomic, retain)UILabel *labelForTitle;
@property (nonatomic, retain)UILabel *labelForDetail;

@end

@implementation XCCellForHeader



-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    
    
    self = [super initWithReuseIdentifier:reuseIdentifier];
    
    if (self) {
     //   self.contentView.backgroundColor = [UIColor yellowColor];
        [self createSubview];
        
    }
    
    return self;
}

- (void) createSubview {
    
    
    self.labelForTitle = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForTitle];
    
   // self.labelForTitle.backgroundColor = [UIColor redColor];
    
    
    self.labelForDetail = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForDetail];
    
  //  self.labelForDetail.backgroundColor = [UIColor greenColor];
    
    
    
    self.buttonForMore = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:self.buttonForMore];
    [self.buttonForMore setTitle:@"更多 >" forState:UIControlStateNormal];
    [self.buttonForMore setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  //  self.buttonForMore.backgroundColor = [UIColor blueColor];
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.labelForTitle.frame = CGRectMake(10 * WIDGHTT, 5 * HEIGHTT, WIDGHT / 4, HEIGHT - 10 * HEIGHTT);
    
    self.labelForDetail.frame = CGRectMake(20 * WIDGHTT + WIDGHT / 4, 5 * HEIGHTT, WIDGHT / 5, HEIGHT - 10 * HEIGHTT);
    self.labelForDetail.textColor = [UIColor grayColor];
    self.labelForDetail.font = [UIFont systemFontOfSize:14];

    
    self.buttonForMore.frame = CGRectMake(WIDGHT / 5 * 4, 5 * HEIGHTT, WIDGHT / 5 - 10 * WIDGHTT, HEIGHT - 10 * HEIGHTT);
    
    
}




- (void)passModel:(XCModelForHeader *)model {


    self.labelForTitle.text = model.name;
   
    
    self.labelForDetail.text = model.desc;
    
    
}


/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
